import socket
import time
# text_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# text_sock.bind((self_ip, text_port))
shutdown_sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ip = '127.0.0.1'
port = 42000
shutdown_sock.connect((ip, port))

print('[+] Unity端连接成功')
msg = str.encode(str(0).ljust(16))
try:
    print('正在关机...')
    shutdown_sock.send(msg) 
except ConnectionResetError:
        print('远程主机已关闭')
time.sleep(1)
shutdown_sock.close()
print('关机成功')

        